/*
 * CanonicalReactionSystem.h
 *
 *  Created on: 7 Sep 2011
 *      Author: Allan
 */

#ifndef CANONICALREACTIONSYSTEM_H_
#define CANONICALREACTIONSYSTEM_H_

// GeoReact includes
#include "ReactionSystem.h"

class CanonicalReactionSystem : public ReactionSystem
{
public:
	CanonicalReactionSystem();
	
	CanonicalReactionSystem(const ReactionSystem& reactions);
	
	CanonicalReactionSystem(const ReactionSystem& reactions, const vector<string>& primarySpecies);
	
	virtual ~CanonicalReactionSystem();
	
	void
	SetPrimarySpecies(const vector<string>& primarySpecies);
	
	const vector<string>& 
	GetPrimarySpecies() const;
	
	const vector<string>& 
	GetSecondarySpecies() const;
	
	const MatrixXd& 
	GetCanonicalStoichiometricMatrix() const;
	
	const VectorXd 
	CanonicalEquilibriumConstants(double T, double P) const;
	
	const VectorXd 
	CanonicalReactionQuotients(const VectorXd& a) const;
	
	const VectorXd 
	CanonicalKineticRates(double T, double P, const VectorXd& n, const VectorXd& a) const;
	
private:
	/// The primary (jSpecies) and equilibrium (eSpecies) species 
	vector<string> jSpecies, eSpecies;
	
	/// The stoichiometric matrix of the canonical reactions
	MatrixXd vej;
	
	/// The stoichiometric matrices for the canonization, where vej = inv(uee)*uej and inv_uee = inv(uee)
	MatrixXd uej, uee, inv_uee;
};

#endif /* CANONICALREACTIONSYSTEM_H_ */
